package com.liandu.dao;

import com.liandu.common.parent.ParentDao;
import com.liandu.entity.CalInfo;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;

import java.util.Date;
import java.util.List;
import java.util.Set;

public interface CalInfoDao extends ParentDao<CalInfo,Long> {

    List<CalInfo> findAllByEcrIDIn(Set<String> ids);

    List<CalInfo> findAllByCalHashIsNull();

    @Query(nativeQuery = true,value = "select *  from calinfo a join ecrinfo b on a.ecrID = b.ecrID join busiinfo c on b.busiId = c.busiInfoID" +
            " where a.calDateTime between ?1 and ?2 and if(?3 is null,1,c.busiName like concat('%',?3,'%'))")
    Page<CalInfo> findAllCalInfo(Date start, Date end, String busiName, Pageable pageable);
}
